//根据经纬度计算两点距离
function toRadians(d){
  return d * Math.PI/180
}
function getDistance(lat1,lng1,lat2,lng2){
  const R = 6378137  //赤道半径
  let dis = 0
  let redLat1 = toRadians(lat1)
  let redLat2 = toRadians(lat2)
  let deltaLat = redLat1 - redLat2
  let deltaLng = toRadians(lng1) - toRadians(lng2)
  dis = 2 * R * Math.asin(Math.sqrt(Math.pow(Math.sin(deltaLat/2),2)
      + Math.cos(redLat1) * Math.cos(redLat2) * Math.pow(Math.sin(deltaLng/2),2)))
      return dis
}
module.exports ={
  getDistance
}